desktop.navbar = {
	init : function() {
		var me = this;
		if (this.rendered !== true) {
			query = function() {
				desktop.win.newWin({
					title : '搜索',
					src : 'knowledge/knowledgeSearch',
					id : 'knowledgeSearch',
					query : true,
				});
			};
			
			note = function() {
				desktop.win.newWin({
					title : '我的信息箱',
					src : 'app/message/myMessageBoxView',
					id : 'myMessageBox',
					width : 960,
					query : true,
					height : 565
				});
			};
			
			var html = '<div id="nav_bar"  class="no_sysbtn">'
					+ '<div class="indicator_wrapper">'
					+ '<div id="indicatorContainer" class="indicator_container nav_current_1">'
					+ '<a class="indicator indicator_header" href="javascript:void(0)" cmd="vip" title="我的信息箱" onclick="note();">'
					+ '<img id="navbarHeaderImg" class="indicator_header_img" alt="我的信息箱" src="img/webos/logo_mini.png"></a>'
					+ this.buildIndicator(3)
					+ '<a class="indicator indicator_search" href="javascript:void(0)" hidefocus="true" cmd="search" title="搜索" onclick="query();"></a>'
//					+ '<a class="indicator indicator_manage" href="javascript:void(0)" hidefocus="true" cmd="manage" title="全局视图，Ctrl + Alt + ↑">'
					+ '</a></div></div></div>';
			$(document.body).append($(html));
			me.element = $('#nav_bar');
			me.rendered = true;
		}
		me.index = 0;
		var navbar = desktop.navbar.element, inner = desktop.container.inner, navtab = navbar
				.find("a.nav_btn"), panel = desktop.container.panel, desktopWidth = panel
				.width(), lBarWidth = 73;
		navbar.draggable({
					scroll : false
				});

		navtab.droppable({
			scope : 'a',
			over : function(event, ui) {
				$(this).trigger("click");
			},
			drop : function(event, ui) {
				var i = navtab.index($(this));
				ui.draggable.addClass("shortcut").insertBefore(panel.eq(i)
						.find(".add_icon")).find("span").addClass("icon");
				desktop.shortcut.init();
				desktop.dockbar.init();
			}
		}).click(function(event) {
			event.preventDefault();
			event.stopPropagation();
			var i = navtab.index($(this));
			if (i != desktop.navbar.index) {
				desktop.shortcut.desktopMove(inner, panel, navtab, 500,
						desktopWidth + lBarWidth, i);
			}

		});
	},

	buildIndicator : function(index) {

		var html = '<a class="indicator nav_btn indicator_1"  hidefocus="true" customacceptdrop="1" cmd="switch" index="1">'
				+ '<span class="indicator_icon_bg"></span>'
				+ '<span class="indicator_icon indicator_icon_1">1</span>'
				+ '</a>'
				+ '<a class="indicator nav_btn indicator_2"  hidefocus="true" customacceptdrop="1" cmd="switch" index="2" >'
				+ '<span class="indicator_icon_bg"></span>'
				+ '<span class="indicator_icon indicator_icon_2">2</span>'
				+ '</a>'
				+ '<a class="indicator nav_btn indicator_3"  hidefocus="true" customacceptdrop="1" cmd="switch" index="3" >'
				+ '<span class="indicator_icon_bg"></span>'
				+ '<span class="indicator_icon indicator_icon_3">3</span>'
				+ '</a>';
		return html;
	}

};
